package com.gps.funnymath.domains;

import java.util.ArrayList;
import java.util.Random;

import com.gps.funnymath.concreteItems.ConcreteNoun;


public class UnitDomain implements Domain{

	static Random random = new Random();
	
	ArrayList<ConcreteNoun> units; // all nouns in domain
	
	String label;

	public UnitDomain(String label){
		
		units = new ArrayList<ConcreteNoun>();
		
		this.label = label;
	}
	
	public boolean add(ConcreteNoun noun){
		return units.add(noun);
	}
	
	public boolean remove(ConcreteNoun noun){
		return units.remove(noun);
	}
	
	public ConcreteNoun getRandom(){
		int index = random.nextInt(units.size());
		return units.get(index);
	}

	@Override
	public boolean contains(Object object) {
		
		if(object instanceof ConcreteNoun){
			
			for (ConcreteNoun concreteUnit : units){
			    if (concreteUnit.equals((ConcreteNoun)object))
			    	return true;
			}
			
		}
		
		return false;
	}
	
}
